﻿@{
    Bundle("jquery_validate");
}
           
<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('@ID("#form")').validate({
            rules: {
                name: {
                    required: true
                },
                code: {
                    required: true
                }
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("Language"))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_language")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("TimeZone"))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_timezone")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
            }
        });
        jQuery('@ID("#ddl_country")').bind('change', function () {
            jQuery.ajax({
                type: 'post',
                url: '@Url.Action(Loc.Act("List").Ctrl("Region"))',
                dataType: 'json',
                data: {
                    countryID: jQuery('@ID("#ddl_country")').val()
                },
                success: function (rsp) {
                    var ddl = jQuery('@ID("#ddl_region")');
                    ddl.empty();
                    jQuery.each(rsp, function (k, v) {
                        ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                    });
                }
            });
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("Country"))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_country")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
                ddl.change();
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("Currency"))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_currency")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("MeasureUnit").Set(new { flagMask = "Dimension" }))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_dimension")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("MeasureUnit").Set(new
            {
                flagMask = "Weight"
            }))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_weight")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("List").Ctrl("MeasureUnit").Set(new
            {
                flagMask = "Information"
            }))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_information")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
            }
        });
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Create").Ctrl("Profile"))" method="post">
    <input type="hidden" name="flags" value="None" />
    <table>
        <tr>
            <td>
                <label>@T(Res.Name("Language"))</label>
            </td>
            <td>
                <select id="@ID("ddl_language")" name="languageID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("TimeZone"))</label>
            </td>
            <td>
                <select id="@ID("ddl_timezone")" name="timeZoneID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Country"))</label>
            </td>
            <td>
                <select id="@ID("ddl_country")" name="countryID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Region"))</label>
            </td>
            <td>
                <select id="@ID("ddl_region")" name="regionID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Currency"))</label>
            </td>
            <td>
                <select id="@ID("ddl_currency")" name="currencyID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("DimensionUnit"))</label>
            </td>
            <td>
                <select id="@ID("ddl_dimension")" name="dimensionUnitID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("WeightUnit"))</label>
            </td>
            <td>
                <select id="@ID("ddl_weight")" name="weightUnitID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("InformationUnit"))</label>
            </td>
            <td>
                <select id="@ID("ddl_information")" name="informationUnitID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("Common").Of("Vocab").Name("Code"))</label>
            </td>
            <td>
                <input type="text" name="code" maxlength="10" />
                <span class="hint">@T(Res.In("WebAdmin").Of("Help").Of("Globalization").Of("Profile").Name("Code"))</span>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Name"))</label>
            </td>
            <td>
                <input type="text" name="name" maxlength="100" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("LocalizationProfileFlags").Name("Active"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="Active" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("LocalizationProfileFlags").Name("Public"))</label>
            </td>
            <td>
                <input type="checkbox" name="flags" value="Public" />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>
